﻿Public Class Form1
    Dim StorePanel As New storecontrol
    Dim EODControl_ As New EODControl
    Dim SendRollOutPanel As New StoreGroupControl
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        StorePanel.Mainform = Me
        SendRollOutPanel.Mainform = Me
        Me.Text = Me.Text & " v" & My.Application.Info.Version.ToString

        TreeView1.ExpandAll()
    End Sub

    Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
        Panel1.Controls.Clear()
        'Panel2.Controls.Add(StorePanel)

        If (TreeView1.SelectedNode.Text = "Store") Then
            Panel1.Controls.Add(StorePanel)
        ElseIf (TreeView1.SelectedNode.Text = "Functions") Then
            Panel1.Controls.Add(StorePanel)
        ElseIf (TreeView1.SelectedNode.Text = "End of Day Controller") Then
            Panel1.Controls.Add(EODControl_)
        ElseIf (TreeView1.SelectedNode.Text = "Send Roll Out") Then
            Panel1.Controls.Add(SendRollOutPanel)
        End If

        Try
            Dim DrawPanelSize As Drawing.Size
            DrawPanelSize.Width = Panel1.Width
            DrawPanelSize.Height = Panel1.Height
            Panel1.Controls.Item(0).Size = DrawPanelSize
        Catch ex As Exception
        End Try
    End Sub

    Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
        Try
            Dim DrawPanelSize As Drawing.Size
            DrawPanelSize.Width = Panel1.Width
            DrawPanelSize.Height = Panel1.Height
            Panel1.Controls.Item(0).Size = DrawPanelSize
        Catch ex As Exception
        End Try
    End Sub

    Private Sub SettingsToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles SettingsToolStripMenuItem1.Click
        Dim a As String
        a = InputBox("Who's your master?")
        If a = "sergentlois" Then
            Dim settingsform As New Settings
            Try
                settingsform.ShowDialog()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Else
            MsgBox("Access Denied!", MsgBoxStyle.Critical)
        End If
    End Sub

    Public Sub Freeze()
        TreeView1.Enabled = False

    End Sub
    Public Sub DeFreeze()
        TreeView1.Enabled = True
    End Sub

    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        Try
            Panel1.Controls.Clear()

            For Each ControlItem As Control In Panel1.Controls
                For Each ArayList As ArrayList In ControlItem.Controls
                    For Each Threads As Threading.Thread In ArayList
                        Threads.Abort()
                    Next
                Next
            Next

        Catch ex As Exception

        End Try

    End Sub
End Class
